<template>
	<view class="jdxx">
		<view class="type">
			<view class="type_item" v-for="(item, index) in typeArr" :key="index">
				<view :style="getColor(item.state)"></view>
				<view>{{ item.name }}</view>
			</view>
		</view>
		<view class="info" v-for="(item, index) in dataArr" :key="index">
			<view :style="getColor(item.nodeStatus)"></view>
			<view>{{ item.nodeName }}</view>
			<view @tap="toView(item)">查看</view>
		</view>
	</view>
</template>

<script>
	import {
		xmglChilrenJdxx
	} from "@/request/zdxm.js"
	export default {
		data() {
			return {
				id: null,
				dataArr: [],
				typeArr: [{
						name: "未开始",
						state: 0,
					},
					{
						name: "进行中",
						state: 1,
					},
					{
						name: "已完成",
						state: 2,
					},
				],
			};
		},
		onLoad(Option) {
			this.id = Option.id
			this.xmglChilrenJdxx()
		},
		methods: {
			xmglChilrenJdxx() {
				xmglChilrenJdxx({
						id: this.id
					})
					.then((res) => {
						this.dataArr = res.data.result.details
					})
			},
			getColor(state) {
				if (state == 0) {
					return "backgroundColor:rgba(205, 211, 224, 1)";
				}
				if (state == 1) {
					return "backgroundColor:rgba(48, 116, 255, 1)";
				}
				if (state == 2) {
					return "backgroundColor:rgba(31, 211, 183, 1)";
				}
				if (state == 3) {
					return "backgroundColor:rgba(248, 95, 120, 1)";
				}
				if (state == 4) {
					return "backgroundColor:rgba(250, 173, 51, 1)";
				}
			},
			toView(x) {
				uni.navigateTo({
					url: "/pages/zdxm/xmgl/jdxx/jdxxck?item="+ JSON.stringify(x),
				});
			},
		},
	};
</script>

<style lang="scss" scoped>
	.jdxx {
		background-color: #f6f7fa;
		min-height: 100vh;

		.type {
			width: 100%;
			height: 80rpx;
			background: #ffffff;
			display: flex;
			flex-flow: row nowrap;
			justify-content: space-around;
			align-items: center;
			padding: 0 30rpx;

			.type_item {
				flex: 1;
				display: flex;
				flex-flow: row nowrap;
				align-items: center;
				justify-content: center;

				view:nth-child(1) {
					width: 12rpx;
					height: 12rpx;
					border-radius: 50%;
					margin-right: 15rpx;
				}
			}
		}

		.info {
			width: 710rpx;
			height: 100rpx;
			background: #ffffff;
			box-shadow: 0rpx 0rpx 24rpx 0rpx rgba(48, 116, 255, 0.1);
			border-radius: 8rpx;
			display: flex;
			flex-flow: row nowrap;
			justify-content: flex-start;
			align-items: center;
			margin: 0 auto;
			margin-top: 30rpx;
			position: relative;

			view:nth-child(1) {
				margin-left: 30rpx;
				width: 12rpx;
				height: 12rpx;
				border-radius: 50%;
			}

			view:nth-child(2) {
				margin-left: 20rpx;
				font-size: 28rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #272b32;
			}

			view:nth-child(3) {
				font-size: 28rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #3074ff;
				position: absolute;
				top: 50%;
				right: 33rpx;
				transform: translateY(-50%);
			}
		}
	}
</style>
